<%@page language="java" 
        import= " org.fiel.FielConstants
                , java.util.ArrayList
                , org.fiel.admin.struts.forms.CargoForm
                , org.fiel.admin.struts.forms.RecursoForm "%>

<%@taglib prefix="bean" uri="/WEB-INF/struts-bean.tld"%>
<%@taglib prefix="logic" uri="/WEB-INF/struts-logic.tld"%>

<jsp:useBean id="areas" type="java.util.List" scope="request"/>

<%
    int cantidadAreas = areas.size();
%>

<script language="javascript">
    showLabel('staff')
</script>

<table border="0" width="100%" style="font-family:verdana,arial;font-size:7pt" width="100%">
    <tr>
        <td width="50%" valign="top">
    
            <logic:iterate name='<%=FielConstants.CARGOS_SIN_AREA%>' id="cargo" type="org.fiel.admin.struts.forms.CargoForm">
                <span>
                    <b><bean:write name="cargo" property="nombre"/>:</b>
                </span>
                <%
                    ArrayList recursos = (ArrayList)cargo.getRecursosSinArea();

                    for(int j=0; j<recursos.size(); j++){
                        RecursoForm recurso = (RecursoForm)recursos.get(j);

                        if( recurso.getCv()!=null && recurso.getCv().trim().length()>0 ){
                            out.write("<a target=\"_blank\" href='/pages/inicio/staff/"+recurso.getId()+"."+recurso.getCv()+"'>"+recurso.getNombre()+" "+recurso.getApellido()+"</a>");
                        }else{
                            out.write(recurso.getNombre() + " "+recurso.getApellido());
                        }

                        out.write((j==(recursos.size()-1))? ". ": ", ");
                    }
                %>
            </logic:iterate>
            <br><br>
    
            <table border="0" cellpadding="3" cellspacing="0" height="100%" style="font-family:verdana,arial;font-size:7pt" width="100%">
                <logic:iterate indexId="index" name='<%=FielConstants.AREAS%>' id="area" type="org.fiel.admin.struts.forms.AreaForm">
                <tr>
                    <td valign="top">
                        <span style="color:#333399;font-family:arial;font-size:9pt;font-style:italic;font-weight:bold;text-transform: uppercase;"><bean:write name="area" property="nombre"/></span>
                        <span style="color:#333399;font-family:arial;font-size:5pt;font-style:italic;font-weight:bold;text-transform: uppercase;" width="100%"><br><br></span>
                        <%
                            ArrayList cargos = (ArrayList)area.getCargos();

                            for(int i=0; i<cargos.size(); i++){
                                CargoForm cargo = (CargoForm)cargos.get(i);
                                out.write("<b>"+cargo.getNombre()+":</b>&nbsp;");

                                ArrayList recursos = (ArrayList)cargo.getRecursosAreas(area.getId());

                                for(int j=0; j<recursos.size(); j++){
                                    RecursoForm recurso = (RecursoForm)recursos.get(j);

                                    if( recurso.getCv()!=null && recurso.getCv().trim().length()>0 ){
                                        out.write("<a target=\"_blank\" href='/pages/inicio/staff/"+recurso.getId()+"."+recurso.getCv()+"'>"+recurso.getNombre()+" "+recurso.getApellido()+"</a>");
                                    }else{
                                        out.write(recurso.getNombre() + " "+recurso.getApellido());
                                    }

                                    out.write((j==(recursos.size()-1))? ". ": ", ");
                                }
                                out.write("<br>");
                            }

                            ArrayList recursos = (ArrayList)area.getRecursosSinCargo();

                            for(int i=0; i<recursos.size(); i++){
                                RecursoForm recurso = (RecursoForm)recursos.get(i);

                                if( recurso.getCv()!=null && recurso.getCv().trim().length()>0 ){
                                    out.write("<a target=\"_blank\" href='/pages/inicio/staff/"+recurso.getId()+"."+recurso.getCv()+"'>"+recurso.getNombre()+" "+recurso.getApellido()+"</a>");
                                }else{
                                    out.write(recurso.getNombre() + " "+recurso.getApellido());
                                }

                                out.write((i==(recursos.size()-1))? ". ": ", ");
                            }
                        %>
                    </td>
                </tr>
                <tr height="20px"><td></td></tr>
                <%if((index.intValue()+1)==Math.ceil(cantidadAreas/2)){%>
            </table>
        </td>
            <td valign="top">
            <table border="0" cellpadding="3" cellspacing="0" height="100%" style="font-family:verdana,arial;font-size:7pt" width="100%">
            <%}%>
        </logic:iterate>
            </table>

        </td>
    </tr>
</table>